#0. init class and attr IDs, Prepare execution CC "Core" GET_ATTR_ID classid:bp-model attrname:"Tweet replies" SET nTweetRepliesAttrID:(attrid) CC "Application" GET_PATH append-delimiter SET sADOxxPath:(path) CC "AdoScript" FILE_EXISTS file:(sADOxxPath + "wget.exe") IF (exists = 0) { CC "AdoScript" FILE_COPY from:"db:\\wget.exe" to:(sADOxxPath + "wget.exe") } #1. Get context parameter for model to be published CC "Modeling" GET_ACT_MODEL SET nCurrentModelID:(modelid) #2. Get Twitter ID from Model CC "Core" GET_ATTR_VAL objid:(nCurrentModelID) attrname:"Tweet ID" SET nTweetID:(val) #3. Get all replies to tweet CC "AdoScript" GET_TEMP_FILENAME SET sReponseFile:(filename + ".txt") #CC "AdoScript" EDITBOX text:(sADOxxPath + "wget.exe --no-check-certificate -O "+sReponseFile+" https://www.adoxx.org/socialmediahook/twitter_replies?tweetID="+ nTweetID + "&format=CSV") SYSTEM (sADOxxPath + "wget.exe --no-check-certificate -O "+sReponseFile+" https://www.adoxx.org/socialmediahook/twitter_replies?tweetID="+ nTweetID + "&format=CSV") #with-console-window CC "AdoScript" FREAD file:(sReponseFile) SET lRepliesCSV:(text) # clean record before import CC "Core" GET_ALL_REC_ATTR_ROW_IDS objid:(nCurrentModelID) attrid:(nTweetRepliesAttrID) SET lRowIDs:(rowids) FOR sRowID in:(lRowIDs) { CC "Core" REMOVE_REC_ROW objid:(nCurrentModelID) attrid:(nTweetRepliesAttrID) rowid:(VAL sRowID) } # add all replies to the record SET nReplyCount:(0) FOR sReply in:(lRepliesCSV) sep:"\n" { IF (LEN sReply != 0) { SET nReplyCount:(nReplyCount+1) CC "Core" ADD_REC_ROW objid:(nCurrentModelID) attrid:(nTweetRepliesAttrID) SET nNewRowID:(rowid) SET sUser:(token (sReply, 0 , ",")) SET sReply:(token (sReply, 1 , ",")) CC "Core" SET_ATTR_VAL objid:(nNewRowID) attrname:"User" val:(sUser) CC "Core" SET_ATTR_VAL objid:(nNewRowID) attrname:"Reply" val:(sReply) } } # 4. Success message CC "AdoScript" INFOBOX (STR nReplyCount + " twitter replies have been added to the model.")